<?php
namespace app\admin\model;

use think\Model;
use think\Db;

class Banner extends Model
{
    //设置当前模型对应数据表名称
    protected $table = 'am_banner';

    //查询该表所有数据
    public function seleceAll()
    {
        $res = $this->select();
        return $res;
    }

    //新增轮播图
    public function insertBanner($data)
    {
        $res = $this->data($data)->save();
        return $res;
    }

    //修改轮播图
    public function updateBanner($id)
    {
        $res = $this->field('*')->where('id='.$id)->find();
        return $res;
    }

    //更新轮播图
    public function editBanner($id,$data)
    {
        $res = $this->allowField('*')->save($data,['id'=>$id]);
        return $res;
    }

    //删除轮播图
    public function deleteBanner($id)
    {
        $res = $this->field('*')->where('id',$id)->delete();
        return $res;
    }
}